<?php require_once('Connections/locamedicadmin.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['locamedic_admin_accesscheck'])) {
  $_SESSION['locamedic_admin_PrevUrl'] = $_GET['locamedic_admin_accesscheck'];
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "index.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_locamedicadmin, $locamedicadmin);
  
  $LoginRS__query=sprintf("SELECT id, pass FROM admin WHERE id='%s' AND pass='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $locamedicadmin) or die(mysql_error());
  
  $loginFoundUser = mysql_num_rows($LoginRS);
  
  if ($loginFoundUser) {
     
	 $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['locamedic_admin_user'] = $loginUsername;

    if (isset($_SESSION['locamedic_admin_PrevUrl'])) {
      $MM_redirectLoginSuccess = $_SESSION['locamedic_admin_PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Locamedic CSRE Admin</title>
<link href="locamedicadmin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="page">

	<?php include('sidebar.php'); ?>
	
	<!-- end sidebar -->
	<div id="content">
		<div align="center"><img src="images/page_image_5.jpg" alt="" /></div>
	  	<div class="boxed">
			<h1 class="title2">Locamedic Admin Page</h1>
			<form method="POST" action="<?php echo $loginFormAction; ?>" name="loginform" id="loginform">
				<input type="hidden" name="login" value="login" />
				<table cellpadding="5" align="center">
				<?php if (isset($_POST['login']) && $loginFoundUser == 0) { ?>
					<tr>
						<td colspan="2" align="center">
							<table>
								<tr>
									<td width="30">
										<img src="images/redCross.png" />
									</td>
									<td>
										user ou mot de passe n'est pas correcte!
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<?php } ?>
					<tr>
						<td>
							<label class="inputtext" for="username">Username:</label>
						</td>
						<td>
							<input id="username" type="text" name="username" value="" class="inputtext" />
						</td>
					</tr>
					<tr>
						<td>
							<label class="inputtext" for="password">Mot de passe:</label>
						</td>
						<td>
							<input id="password" type="password" name="password" value="" class="inputtext" />
						</td>
					</tr>
				</table>
				<div class="botonera">
					<input id="inputsubmit1" type="submit" name="inputsubmit1" value="Sign In" class="submitbut" />
				</div>
		  </form>
	  </div>
  </div>
	<!-- end content -->
	<div style="clear: both;">&nbsp;</div>
</div>
<!-- end page -->

<?php include('footer.php'); ?>

</body>
</html>
